package main

import (
	"fmt"
	"reflect"
	"strconv"
)

type order struct {
	OrdId      int
	CustomerId int
}

type employee struct {
	Name    string
	Id      int
	Address string
	Salary  int
	Country string
}

func createQuery(o interface{}) string {

	if reflect.TypeOf(o).Kind() == reflect.Struct {
		v := reflect.ValueOf(o)
		tableName := reflect.TypeOf(o).Name()
		result := "intert into " + tableName + " "
		values := "vaules("
		for i := 0; i < v.NumField(); i++ {
			if v.Field(i).Kind() == reflect.Int {
				values += strconv.Itoa(int(v.Field(i).Int())) + ", "
			}
			if v.Field(i).Kind() == reflect.String {
				values += "\"" + v.Field(i).String() + "\"" + ", "
			}
		}
		values = values[0 : len(values)-2]
		values += ")"
		result += values
		fmt.Println(result)
		return result
	} else {
		fmt.Println("unsupport kind")
		return "unsupport kind"
	}

}

func main() {
	o := order{

		OrdId:      456,
		CustomerId: 56,
	}
	createQuery(o)

	e := employee{
		Name:    "Naveen",
		Id:      565,
		Address: "Coimbatore",
		Salary:  90000,
		Country: "India",
	}
	createQuery(e)
	i := 90
	createQuery(i)
}
